// import 与 import type 之间的差异，import type不参与编译，只进行类型检测
import type {
  loginResponseModel,
  userInfoResponseModel,
} from './model/loginModel'
import request from '@/utils/request'

enum Api {
  Login = '/admin/acl/index/login',
  getUserInfo = '/admin/acl/index/info',
  Logout = '/admin/acl/index/logout',
}

// 登录接口的定义
export const loginApi = (username: string, password: string) => {
  // 对返回的内容进行了数据类型的约束
  return request.post<any, loginResponseModel>(Api.Login, {
    username,
    password,
  })
}

// 获取用户信息
export const getUserInfoApi = () => {
  return request.get<any, userInfoResponseModel>(Api.getUserInfo)
}

// 退出登录
export const logoutApi = () => {
  return request.post(Api.Logout)
}
